<template>
  <div class="demo">
    <h1>学校名字:{{name}}</h1>
    <h2>学校地址:{{address}}</h2>
</div>
</template>

<script>
    export default {
        name: "SchoolInfo",
        props: ['getSchooolName'],
        data() {
            return {
                name: "尚硅谷",
                address: "北京市海淀区西二旗"
            }
        },
        mounted() {
            // console.log("School", this.x);
            this.$bus.$on('hello', (studentName) => {
                 console.log("School组件收到了Student组件传过来的数据", studentName);
            });
        },
        beforeDestroy() {
            // 组件销毁时，取消自定义事件
            this.$bus.$off('hello');
        }
        
    }
</script>

<style scoped lang="less">
    .demo{
        color:brown;
        background-color: skyblue;
        .atguigu {
            font-size: 40px;
        }
    }
</style>